/*
 * To change this FTemplate, choose Tools | FTemplates
 * and open the FTemplate in the editor.
 */
package entry;

import ast.ParseException;
import ast.SimpleNode;
import ast.TokenMgrError;
import ast.WAVEParser;
import base.Utilities;
import debug.DebugFrame;
import java.io.StringReader;
import wave.WaveInterpreter;

/**
 *
 * @author Tue
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        //In ra AST cua chuoi wave
        //Main.parse("#.Fx=P");
        try {
            WaveInterpreter waveInterpreter = WaveInterpreter.getInstance();
            DebugFrame db = new DebugFrame();
            Utilities.debugMode=false;
            waveInterpreter.start();
            System.out.println("MAC: " + Utilities.getMACAddress() + Utilities.isLocalHost("192.168.1.8"));
            //waveInterpreter.injectWave("@#a$$`192.168.1.1'");
            while(true){
                System.out.println(waveInterpreter.getKN());
                Thread.sleep(3000);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }   
    }

    public static void parse(String query) {
        SimpleNode root = null;
        WAVEParser parser = new WAVEParser(new StringReader(query));
        try {
            root = parser.Wave();
            System.out.println("Cay cu phap cua chuoi: " + query);
            root.setStringAll();
            root.dump("");
        } catch (ParseException pe) {
            System.out.println("parse(): an invalid expression!" + pe.toString());
        } catch (TokenMgrError e) {

            System.out.println("a Token Manager error!" + e.toString());

        }
    }
}
